package com.book.a20210523;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class QqUtils {
    private final static String mqqapi = "mqqapi://forward/url?plg_auth=1&url_prefix=";
    public static void openQQWeb(Context context ,String url){
        final Base64.Encoder encoder = Base64.getEncoder();
        byte[] arr = url.getBytes(StandardCharsets.UTF_8);
        String encodedText = encoder.encodeToString(arr);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData( Uri.parse(mqqapi+encodedText));

        try {
            context.startActivity(intent);
        } catch (Exception e) {
            Toast.makeText(context,"未安装手Q或安装的版本不支持"+e.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
}
